<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'account.label', default: 'Account')}"/>
    <title>机构管理</title>
    <style>
    .table>tbody>tr>td{
        vertical-align: middle;
    }
    @media screen and (min-width:1900px) and (max-width:1920px) {
        .flex{
            display: flex;justify-content: center;align-items: center;
        }
    }
    .select2-container .select2-choices .select2-search-field input,.select2-container .select2-choice,.select2-container .select2-choices{

        color: #999;
    }
    </style>
</head>

<body class="fixed-navbar fixed-sidebar">

<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right navFloatRight">
                <ol class="hbreadcrumb breadcrumb">
                    <li>
                        <span>CINDTATA PLS</span>
                    </li>
                    <li class="active">
                        <span>机构管理</span>
                    </li>
                </ol>
            </div>
            <h2 class="font-light m-b-xs">
                机构管理
            </h2>
        </div>
    </div>
</div>

<div class="content animate-panel">
    <div class="row">
        <g:form method="POST" action="externalAccountIndex" class="form-horizontal" role="form" id="form">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    <div class="panel-tools">
                        <button class="btn btn-primary btn-xs" type="submit" onclick="text()"><i class="fa fa-search"></i> 查询</button>
                        <button class="btn btn-warning2 btn-xs" type="button" id="resetBtn">
                            <i class="fa fa-times"></i> 重置</button>
                    </div>
                    查询
                </div>
                <div class="panel-body seach-group" id="bug1">
                    %{--第一行--}%
                    <div class="row">
                        <div class="form-group col-sm-4">
                            <label class="col-sm-3 control-label">机构名称</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="name" id="name" value="${params?.name}" placeholder="请输入机构名称">
                                <input type="hidden" class="form-control" name="code" id="code" value="${params?.code}" >
                            </div>
                        </div>
                        <div class="form-group col-sm-4">
                            <label class="col-sm-3 control-label">机构联系人</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="contact" id="contact" value="${params?.contact}" placeholder="请输入机构联系人">
                            </div>
                        </div>
                    <div class="form-group col-sm-4">
                        <label class="col-sm-3 control-label">机构联系方式</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="phone" id="phone" value="${params?.phone}" placeholder="请输入机构联系方式">
                        </div>
                    </div>
                    </div>
                    <div class="row">
                        <div class="form-group col-sm-4">
                            <label for="district" class="col-sm-3 control-label">城市</label>
                            <div class="col-sm-9">
                                <g:select class="form-control" name="city" id="city"
                                          from="${com.cindata.City.list()}"
                                          valueMessagePrefix="status" optionKey="zoneNumber" optionValue="name"
                                          value="${params?.city}"
                                          noSelection="${["-1": '请选择城市']}"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-4">
                            <label for="district" class="col-sm-3 control-label">行政区</label>
                            <div class="col-sm-9 district">
                                <g:select class="form-control" name="district" id="district"
                                          from="${districtList}"
                                          valueMessagePrefix="status" optionKey="zoneNumber" optionValue="name"
                                          value="${params?.district}"
                                          noSelection="${["-1": '请选择行政区']}"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-4">
                            <label for="district" class="col-sm-3 control-label">经营状态</label>
                            <div class="col-sm-9 district">
                                <g:select class="form-control" name="operatingState" id="operatingState" from="${com.cindata.Account.constrainedProperties.operatingState.inList}" value="${params?.operatingState}"
                                  noSelection="${['': '请选择经营状态']}"/>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group col-sm-4">
                            <label for="district" class="col-sm-3 control-label">企业法人</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="fullName" id="fullName" value="${params?.fullName}" placeholder="请输入企业法人">
                            </div>
                        </div>
                        %{--<div class="form-group col-sm-4">--}%
                            %{--<label for="district" class="col-sm-3 control-label">阶段</label>--}%
                            %{--<div class="col-sm-9 district">--}%
                                %{--<g:select class="form-control" name="stage" id="stage" from="${com.cindata.dictionary.AccountStage.list()}" optionKey="id" optionValue="name" value="${params?.stage}" noSelection="${['': '请选择阶段']}"/>--}%
                            %{--</div>--}%
                        %{--</div>--}%
                        <div class="form-group col-sm-4">
                            <label for="district" class="col-sm-3 control-label">启用状态</label>
                            <div class="col-sm-9 district">
                                <g:select class="form-control" name="status" id="status" from="${[[name:'启用',value:1], [name:'禁用',value:0]]}" optionValue="name" optionKey="value" value="${params?.status}" noSelection="${['': '请选择启用状态']}"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </g:form>
    </div>
    
    <div class="row">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                    <g:if test="${params?.code == 'DeveloperAccount'}">
                        <g:link controller="developer" action="search" class="btn btn-success btn-xs">开发商查询</g:link>
                    </g:if>
                    <g:link action="externalAccountCreate" class="btn btn-info btn-xs" params="${params}"><i class="fa fa-plus"></i>新增</g:link>
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                全部机构
            </div>

            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table cellpadding="1" cellspacing="1" class="table table-striped table-bordered table-hover text-center" id="esateTable">
                        <thead>
                        <tr>
                            <g:sortableColumn property="name" title="机构名称" class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="city" title="城市" class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="district" title="行政区" class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="fullName" title="企业法人" class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="operatingState" title="经营状态" class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="contact" title="机构联系人" class="col-md-1 text-center" params="${params}"/>
                            <g:sortableColumn property="phone" title="机构联系方式" class="col-md-1 text-center" params="${params}"/>
                            %{--<g:sortableColumn property="workflow" title="工作流" class="col-md-1 text-center" params="${params}"/>--}%
                            %{--<g:sortableColumn property="stage" title="工作流阶段" class="col-md-1 text-center" params="${params}"/>--}%
                            <g:sortableColumn property="status" title="启用状态" class="col-md-1 text-center" params="${params}"/>
                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${accountList}">
                            <tr>
                                <td><g:link style="color: #3498DB" action="externalAccountShow" id="${it?.id}" params="${params}" class="firstTd">${it?.name}</g:link></td>
                                <td>${it?.city?.name ? it?.city?.name : '-'}</td>
                                <td>${it?.district?.name ? it?.district?.name : '-'}</td>
                                <td>${it?.fullName ? it?.fullName : '-'}</td>
                                <td>${it?.operatingState ? it?.operatingState : '-'}</td>
                                <td>${it?.contact ? it?.contact : '-'}</td>
                                <td>${it?.phone ? it?.phone : '-'}</td>
                                %{--<td>${it?.workflow ? it?.workflow?.name : '-'}</td>--}%
                                %{--<td>--}%
                                    %{--<g:if test="${com.cindata.WorkflowInstance.findByAccountAndWorkflow(it,it?.workflow)?.stage}">--}%
                                        %{--${com.cindata.WorkflowInstance.findByAccountAndWorkflow(it,it?.workflow)?.stage?.name}--}%
                                    %{--</g:if>--}%
                                    %{--<g:else>--}%
                                        %{-----}%
                                    %{--</g:else>--}%
                                %{--</td>--}%
                                <td>${it?.status ? '启用':'禁用'}</td>
                            </tr>
                        </g:each>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="panel-footer">
                <div class="pagination">
                    <g:paginate action="externalAccountIndex" total="${accountCount ?: 0}" params="${params}"/>
                </div>
            </div>
        </div>
    </div>
</div>




<g:javascript>
    
    $(function () {

        var flag;
        $("#city").bind("change", function(){
            if('${params.district}'== $("#district option:selected").val()&&flag!=true && '${params.district}' != '-1'){
                flag=true
                return
            }
            $("#district option").remove();
            $("#s2id_district span:first").html("请选择行政区");
            var city = $("#city").val()
            $("#district").append("<option value='-1' >请选择行政区</option>")
            if(city=='-1'){
                return
            }
            $.ajax({
                url: "/estate/districtList",
                type: "POST",
                data: {'city': city} ,
                success: function(result){
                    for(var i=0; i < result.districtList.length; i++){
                        $("#district").append("<option value=" + result.districtList[i].zoneNumber + ">" + result.districtList[i].name + "</option>")
                    }
                }
            });
        });
        $("#city").change();

        //重置按钮
        $("#resetBtn").click(function () {
            $("#name").val("");
            $("#contact").val("");
            $("#phone").val("");
            $("#s2id_city span:first").html("请选择城市");
            $("#city").val("");
            $("#s2id_district span:first").html("请选择行政区");
            $("#district").val("");
            $("#s2id_operatingState span:first").html("请选择经营状态");
            $("#operatingState").val("");
            $("#fullName").val("");
            $("#s2id_stage span:first").html("请选择阶段");
            $("#stage").val("");
            $("#s2id_status span:first").html("请选择启用状态");
            $("#status").val("");
        });
    });


</g:javascript>

</body>
</html>
